home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / MacMarlais 0.5.3 / Information / HACKING < prev    next >
Encoding:
Text File  |  1994-08-21  |  2.6 KB  |  56 lines  |  [TEXT/Mrls]

  1.  
  2. Guide to modifying Marlais
  3.  
  4. * Adding a data type - There are actually two representations of
  5. Marlais objects.  When SMALL_OBJECTS is not defined, every object is
  6. represented by a struct object that contains a TYPE field and a union
  7. holding the information specific to that object (if there is any).
  8. This is great for debugging because you can easily look inside any
  9. object in a debugger.  The disadvantage is that because of C union
  10. semantics, every object is a big as the largest object.  Object is
  11. simply typedefed to struct object *.  When adding a new type of
  12. object, you need to add a new type name to the objtype enum, add a new
  13. struct containing the necessary information, and then add an entry in
  14. the struct object union.  You should also add the class to the class
  15. hierarchy (init_class_hierarchy) and have objectlcass() return the
  16. correct value in class.c
  17.  
  18. When SMALL_OBJECTS is defined, Object is a word that contain either a
  19. pointer or some immediate data depending on the value of last two bits
  20. in that word.  To add a new immediate type (the data part must be
  21. smaller than 26 bits) add new type tag (ends in SUB), add a new
  22. predicate (ends in P), add a new value extractor if there is actually
  23. a value (ends in VAL), and a macro for synthesizing that immediate
  24. type (starts with MAKE).  To add a new, non-immediate, type add a
  25. struct containing the object type in the first word and the rest of
  26. the values after that.
  27.  
  28. All object slot accesses should take place through macros in case the
  29. object representation changes (again).
  30.  
  31. * Adding a new primitive function - To add a primitive to an existing
  32. file that already defines primtives you must perform the following
  33. steps.  
  34.  
  35.     1) Put a prototype above the struct primitive declaration. 
  36.     2) Add an entry in the struct primitive declaration; see
  37.     object.h for information on the meaning of the prim_type
  38.     field.  The name of the resulting function should be begin
  39.     with '%'.
  40.     3) Add the function to the bottom of the file.  The convention
  41.     is to do no type checking in the C function and do the type
  42.     checking with the generic function call mechanism in the
  43.     wrapper function.
  44.     4) Add a wrapper function to init.dyl.
  45.  
  46. To add a whole new file of primitives, you need to provide a struct
  47. primitive structure and a function called init_xxxx_prims().  You need
  48. to add a call to the init function in main.c: initialize_marlais().
  49.  
  50. * Adding new syntax - All of the syntax form definitions are in
  51. syntax.c.  You need to add a prototype, add an entry in
  52. syntax_operators[], add an entry in syntax_functions[], and write the
  53. function that will evaluate the form.  The function should accept a
  54. single argument which is the whole form to be evaluated.
  55.  
  56.